<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <title>朝代更新 - 领导日程说明系统</title>
    <meta th:replace="~{include/all_include ::  title}"/>
    <link
            th:href="@{/common/resource/H-ui.admin/static/h-ui.admin/css/H-ui.login.css}"
            rel="stylesheet" type="text/css" />
    <meta name="keywords" content="领导日程说明系统-登录">
    <meta name="description" content="领导日程说明系统-登录">
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span>示例模块
    <span class="c-gray en">&gt;</span> 朝代更新
    <a class="btn btn-success radius r" style="line-height: 1.6em; margin-top: 3px"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<article class="page-container">
    <form class="form form-horizontal" id="form-article-add"
          enctype="multipart/form-data"
          th:action="@{/back/demo/dynastyUpdateSubmit}">
        <input type="hidden" name="entity.id" th:value="${one?.id }">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">
                <span class="c-red">*</span>名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" th:value="${one?.name }" placeholder=""
                       id="name" name="entity.name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">
                <span class="c-red">*</span>首都：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" th:value="${one?.capital }" placeholder=""
                       id="capital" name="entity.capital">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">
                <span class="c-red">*</span>开国时间：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" th:value="${one?.stYear }" placeholder=""
                       id="stYear" name="entity.stYear">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">
                <span class="c-red">*</span>亡国时间：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" th:value="${one?.edYear }" placeholder=""
                       id="edYear" name="entity.edYear">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">
                <span class="c-red">*</span>发布时间：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text"  readonly="readonly" th:value="${#dates.format(one.pubTime,'yyyy-MM-dd HH:mm:ss')}"
                       onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"
                       id="pubTime" name="pubTime">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">
                状态：
            </label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <th:block th:each="enumsTemp: ${one?.enumsJson.getJSONArray('STATUS')}">
                    <div class="radio-box">
                        <label>
                            <input name="entity.status" type="radio" th:id="${enumsTemp.enumsVal}" th:value="${enumsTemp.code}" th:checked="${one?.status == enumsTemp.code}">
                            <th:block th:text="${enumsTemp.info}"/>
                        </label>
                    </div>
                </th:block>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">内容：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <script name="entity.content" id="editor" type="text/plain" style="width:100%;height:400px;"></script>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>
<footer th:replace="~{include/all_include ::  footer}"/>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" th:src="@{/common/resource/H-ui.admin/lib/My97DatePicker/4.8/WdatePicker.js}"></script>
<script type="text/javascript" th:src="@{/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/jquery.validate.js}"></script>
<script type="text/javascript" th:src="@{/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/validate-methods.js}"></script>
<script type="text/javascript" th:src="@{/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/messages_zh.js}"></script>
<script type="text/javascript" th:src="@{/common/resource/H-ui.admin/lib/webuploader/0.1.5/webuploader.min.js}"></script>
<script type="text/javascript" th:src="@{/common/resource/H-ui.admin/lib/ueditor/1.4.3/ueditor.config.js}"></script>
<script type="text/javascript" th:src="@{/common/resource/H-ui.admin/lib/ueditor/1.4.3/ueditor.all.min.js}"> </script>
<script type="text/javascript" th:src="@{/common/resource/H-ui.admin/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js}"></script>
<script type="text/javascript" th:inline="javascript">
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        //表单验证
        $("#form-article-add").validate({
            rules:{
                'entity.name':{
                    required:true,
                },
                'entity.capital':{
                    required:true,
                    minlength:4,
                    maxlength:50
                },
                'entity.stYear':{
                    required:true,
                    number:true,
                },
                'entity.edYear':{
                    required:true,
                    number:true,
                }
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                $(form).ajaxSubmit({
                    type: 'post',
                    success: function(data){
                        console.log("==data==",data)
                        data = JSON.parse(data);
                        layer.msg(data.info,{icon:1,time:3000},function(){
                            /* 关闭当前窗口 */
                            if (data.code == '0') {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.$('.btn-refresh').click();
                                parent.layer.close(index);
                            }
                        });
                    },
                    error: function(XmlHttpRequest, textStatus, errorThrown){
                        layer.msg('error!',{icon:1,time:1000});
                    }
                });
            }
        });

        var ue = UE.getEditor('editor');
        var content = [[${one?.content}]];
        /* 百度编辑器提供的方法 */
        ue.addListener("ready", function () {
            /* 为百度编辑器赋值 */
            ue.setContent(content);
        });
    });
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>